/**let p = stack.pop
 * @param {string[]} tokens
 * @return {number}
 */
var evalRPN = function (tokens) {
  let stack = [];
  for (let i = 0; i < tokens.length; ++i) {
    if (
      tokens[i] !== "+" &&
      tokens[i] !== "-" &&
      tokens[i] !== "*" &&
      tokens[i] !== "/"
    ) {
      stack.push(Number(tokens[i]));
    } else {
        let  p =stack.pop()
        let  l = stack.pop();
      if (tokens[i] === "+") {
        stack.push(l + p);
      } else if (tokens[i] === "-") {
        stack.push(l - p);
      } else if (tokens[i] === "*") {
        stack.push(l * p);
      } else if (tokens[i] === "/") {
        let result = l / p;
        stack.push(result > 0 ? Math.floor(result) : Math.ceil(result));
      }
    }
  }
  return stack.pop();
};
